package com.pjh.shitang.utils.helpers;

import java.lang.reflect.Field;
import java.util.Objects;

/**
 * @author yueyinghaibao
 * @date 2022/4/22
 */
public class PropertiesHelper<T> {

    public static <T> boolean isAnyNull(T obj) {
        if(Objects.isNull(obj)) {
            return true;
        }
        Field [] fields = obj.getClass().getDeclaredFields();
        for(Field f : fields) {
            f.setAccessible(true);
            Object value;
            try {
                value = f.get(obj);
                if(value == null) {
                    return true;
                }
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
        }
        return false;
    }

    public static <T> boolean isNull(T obj) {
        return Objects.isNull(obj);
    }
}
